package com.yq.service;


import com.yq.dao.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    AccountMapper accountMapper;

    @Override
    public int remittance(int fromIfd, int destId, int money) {
        // 判断formid里边钱是否还够
        double fromIdMoney = accountMapper.selectMoney(fromIfd);
        if (fromIdMoney < (double)money ){
            return 403;
        }
        int count  = accountMapper.reduce(fromIfd,money);
        int count1 = accountMapper.add(destId,money);
        if (count==1 && count1 ==1){
            return 200;
        }
        return 404;
    }
}
